package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitIntoCarRecord;
import com.ruoyi.bus.service.IWitIntoCarRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上车记录表Controller
 * 
 * @author caiyanshan
 * @date 2021-07-29
 */
@RestController
@RequestMapping("/bus/intocarrecord")
public class WitIntoCarRecordController extends BaseController
{
    @Autowired
    private IWitIntoCarRecordService witIntoCarRecordService;

    /**
     * 查询上车记录表列表
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitIntoCarRecord witIntoCarRecord)
    {
        startPage();
        List<WitIntoCarRecord> list = witIntoCarRecordService.selectWitIntoCarRecordList(witIntoCarRecord);
        return getDataTable(list);
    }

    /**
     * 导出上车记录表列表
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:export')")
    @Log(title = "上车记录表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitIntoCarRecord witIntoCarRecord)
    {
        List<WitIntoCarRecord> list = witIntoCarRecordService.selectWitIntoCarRecordList(witIntoCarRecord);
        ExcelUtil<WitIntoCarRecord> util = new ExcelUtil<WitIntoCarRecord>(WitIntoCarRecord.class);
        return util.exportExcel(list, "intocarrecord");
    }

    /**
     * 获取上车记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(witIntoCarRecordService.selectWitIntoCarRecordById(recordId));
    }

    /**
     * 新增上车记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:add')")
    @Log(title = "上车记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitIntoCarRecord witIntoCarRecord)
    {
        return toAjax(witIntoCarRecordService.insertWitIntoCarRecord(witIntoCarRecord));
    }

    /**
     * 修改上车记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:edit')")
    @Log(title = "上车记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitIntoCarRecord witIntoCarRecord)
    {
        return toAjax(witIntoCarRecordService.updateWitIntoCarRecord(witIntoCarRecord));
    }

    /**
     * 删除上车记录表
     */
    @PreAuthorize("@ss.hasPermi('bus:intocarrecord:remove')")
    @Log(title = "上车记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(witIntoCarRecordService.deleteWitIntoCarRecordByIds(recordIds));
    }
}
